import { RequestBody } from 'alova';

import ApiClient from '@/api/apiClient';

/**
 * @description 用户注册接口
 */
export const loginUserRegisterApi = (data: RequestBody) => {
	return ApiClient.Post('/user/register', data);
};

/**
 * @description 获取SSO认证中心登录地址
 */
export const loginUserSsoLoginApi = (data: RequestBody) => {
	return ApiClient.Get('/sso/getSsoAuthUrl', {
		params: data,
		meta: { auth: true }
	});
};
/**
 * @description 获取SSO认证中心返回的Ticket 进行登录
 */
export const loginUserLoginByTickerApi = (data: RequestBody) => {
	return ApiClient.Get('/sso/doLoginByTicket', {
		params: data,
		meta: { auth: true }
	});
};

/**
 * @description 获取sso用户信息
 */
export const loginSsoUserInfoApi = (data?: RequestBody) => {
	return ApiClient.Get('/sso/getUser', {
		params: data
	});
};
/**
 * @description 退出登录
 */
export const loginSsoLogoutInfo = () => {
	return ApiClient.Get('/sso/logout', {
		meta: { auth: true }
	});
};
/** 用ticker 换token */
export const loginSsoGetTokenByTicket = (data: RequestBody) => {
	return ApiClient.Post('/sso/auth', data, {
		meta: { auth: true, baseURL: import.meta.env.VITE_BASE_SSO_API }
	});
};

/** 判断是否已经登录 */
export const loginSsoCheckLogin = (data: RequestBody, url: string) => {
	return ApiClient.Post(`/sso/getRedirectUrl?url=${url}`, data, {
		meta: { auth: true, baseURL: import.meta.env.VITE_BASE_SSO_API }
	});
};

/** SSo登录 */
export const loginSsoLogin = (data?: RequestBody) => {
	return ApiClient.Post('/sso/doLogin', data, {
		meta: { auth: true, baseURL: import.meta.env.VITE_BASE_SSO_API }
	});
};
